Những câu hỏi liên quan
Dung Nguyễn
Xem chi tiết
Hoài thịnh
Xem chi tiết
thu thu
Xem chi tiết
Yna Lolipop
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 3 2022 lúc 23:11

1:

#include <bits/stdc++.h>

using namespace std;

long long dem,i,n,x;

int main()

{

cin>>n;

dem=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x%2==0) dem++;

}

cout<<dem;

return 0;

}

Câu 2: 

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t;

int main()

{

cin>>n;

t=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x%3==0) t+=x;

}

cout<<t;

return 0;

}

Bình luận (0)
☆⩸Moon Light⩸2k11☆
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 5 2022 lúc 1:04

b:

uses crt;

var i,n,s:integer;

begin

clrscr;

readln(n);

s:=0;

for i:=1 to n do s:=s+2*i;

writeln(s);

readln;

end.

c: 

uses crt;

var i,n,s:integer;

begin

clrscr;

readln(n);

s:=0;

for i:=1 to n do s:=s+i;

writeln(s);

readln;

end.

d: 

uses crt;

var i,n,s:integer;

begin

clrscr;

readln(n);

s:=0;

for i:=0 to n do s:=s+2*i+1;

writeln(s);

readln;

end.

Bình luận (0)
Lê Thanh Tuyền
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 2 2021 lúc 11:58

Bài 1: 

function canbac2(x:longint):real;

begin

canbac2:=sqrt(x);

end;

Bài 2: 

function tong(n:longint):longint;

var s,i:longint;

begin

s:=0;

for i:=1 to n do 

  s:=s+i;

tong:=s;

end;

Bình luận (0)
Thanh Thanh
Xem chi tiết
09 Lê Quang HIếu
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 2 2022 lúc 23:34

#include <bits/stdc++.h>

using namespace std;

double s,a;

int i,n;

int main()

{

cin>>a;

s=0;

n=0;

while (s<=a) 

{

n=n+1;

s=s+1/(n*1.0);

}

cout<<n;

return 0;

}

Bình luận (1)
Nguyễn Minh Đức
Xem chi tiết
Nguyễn Lê Phước Thịnh
27 tháng 2 2022 lúc 14:45

#include <bits/stdc++.h>

using namespace std;

long long i,n;

double s;

int main()

{

cin>>n;

s=0;

for (i=1; i<=n; i++)

{

if (i%2!=0) s=s+1/(i*1.0);

else s=s-1/(i*1.0);

}

cout<<fixed<<setprecision(2)<<s;

return 0;

}

Bình luận (0)